﻿// VOR2 Receiver  - 下滑道指示仪

#include "VOR2.h"

void drawVOR2(double x0, double y0, double r, double dot,int VOR2DR)
{
    int width = x0 * 2;
    int height = y0 * 2;
    int radius = r;
    double circle_x = width / 2;
    double circle_y = height / 2;
    double circle_r = radius;

    //    initgraph(width, height, INIT_RENDERMANUAL);//手动渲染
    //    ege_enable_aa(true);//抗锯齿
    //    setbkcolor(WHITE);//背景
    //    setfillcolor(EGERGB(102, 102, 102));//矩形颜色
    //    ege_fillrect(width / 2 - radius * 1.16667, height / 2 - radius * 1.25, radius * 2.333, radius * 2.5);//矩形
        //填充外圆
    setfillcolor(EGERGB(55, 55, 55));
    ege_fillellipse(width / 2 - radius, height / 2 - radius, 2 * radius, 2 * radius);
    //内圆加痕
    //setcolor(EGEARGB(0xFF, 0x20, 0x20, 0x20));
    setcolor(EGERGB(30, 30, 30));
    setlinewidth(radius * 0.03333);//8
    ege_ellipse(width / 2 - radius, height / 2 - radius, 2 * radius, 2 * radius);

    //中间部分
    //setcolor(EGEARGB(0xFF, 0x33, 0x33, 0x33));
    setcolor(EGERGB(45, 45, 45));
    setlinewidth(radius * 0.12083);//29
    ege_ellipse(width / 2 - radius - radius * 0.04583, height / 2 - radius - radius * 0.04583, 2 * radius + radius * 0.09167, 2 * radius + radius * 0.09167);


    setcolor(EGERGB(20, 20, 20));
    setlinewidth(radius * 0.01666);//4
    ege_ellipse(width / 2 - radius + radius * 0.00833, height / 2 - radius + radius * 0.00833, 2 * radius, 2 * radius);//2  2  2*r   2*r


    setcolor(EGERGB(45, 45, 45));
    setlinewidth(radius * 0.02916);//7
    ege_ellipse(width / 2 - radius + radius * 0.02083, height / 2 - radius + radius * 0.02083, 2 * radius - radius * 0.04166, 2 * radius - radius * 0.04166);//5  5  -10  -10

    setcolor(EGERGB(15, 15, 15));
    setlinewidth(radius * 0.02916);//7
    ege_ellipse(width / 2 - radius + radius * 0.04166, height / 2 - radius + radius * 0.04166, 2 * radius - radius * 0.08333, 2 * radius - radius * 0.0833);//  10  10  -20  -20


    //外圆框
    setcolor(BLACK);
    setlinewidth(radius * 0.025);//6
    ege_ellipse(width / 2 - radius - radius * 0.1167, height / 2 - radius - radius * 0.1167, 2 * radius + radius * 0.1167 * 2, 2 * radius + radius * 0.1167 * 2);
    //记号
    setcolor(BLACK);//描边颜色
    setlinewidth(radius * 0.00625);//线条粗细//
    ege_circle(circle_x, circle_y, circle_r + circle_r / 10);//描边

    ege_point p5 = { circle_x - circle_r - circle_r / 10 + circle_r / 30 * 11 ,circle_y - circle_r - circle_r / 10 + circle_r / 30 * 11 };
    ege_setpattern_ellipsegradient(p5, EGERGB(160, 160, 160), circle_x - circle_r - circle_r / 10, circle_y - circle_r - circle_r / 10, 2 * (circle_r + circle_r / 10), 2 * (circle_r + circle_r / 10), EGEACOLOR(0xFF, 0x00161616));
    ege_fillrect(circle_x - circle_r - circle_r / 10, circle_y - circle_r - circle_r / 10, 2 * (circle_r + circle_r / 10), 2 * (circle_r + circle_r / 10));

    //最外圈


    setcolor(BLACK);//描边颜色
    setlinewidth(radius * 0.01666);//线条粗细//4
    ege_circle(circle_x, circle_y, circle_r + circle_r / 150);//描边

    ege_point p6 = { circle_x - circle_r - circle_r / 300 * 2 + circle_r / 30 * 9 ,circle_y - circle_r - circle_r / 300 * 2 + circle_r / 30 * 9 };
    ege_setpattern_ellipsegradient(p6, EGERGB(140, 140, 140), circle_x - circle_r - circle_r / 300 * 2, circle_y - circle_r - circle_r / 300 * 2, 2 * (circle_r + circle_r / 300 * 2), 2 * (circle_r + circle_r / 300 * 2), EGEACOLOR(0xFF, 0x003A3A3C));
    ege_fillrect(circle_x - circle_r - circle_r / 300 * 2, circle_y - circle_r - circle_r / 300 * 2, 2 * (circle_r + circle_r / 300 * 2), 2 * (circle_r + circle_r / 300 * 2));

    //setfillcolor(EGERGB(80, 80, 80));//填充为灰色
    //ege_fillcircle(circle_x, circle_y, circle_r + circle_r / 300 * 2);//圆形边框
    //第二圈


    setlinewidth(radius * 0.02);//线条粗细
    //setfillcolor(EGERGB(55, 55, 55));//填充为灰色





    ege_point p7 = { circle_x  ,circle_y };
    //ege_setpattern_ellipsegradient(p7, EGERGB(75, 75, 75), circle_x - circle_r + circle_r / 30, circle_y - circle_r + circle_r / 30, 2 * (circle_r - circle_r / 30), 2 * (circle_r - circle_r / 30), EGEACOLOR(0xFF, 0x00292925));
    //ege_fillrect(circle_x - circle_r + circle_r / 30, circle_y - circle_r + circle_r / 30, 2 * (circle_r - circle_r / 30), 2 * (circle_r - circle_r / 30));
    ege_circle(circle_x, circle_y, 0.975 * radius);//描边

    setfillcolor(EGERGB(10, 10, 10));
    ege_fillcircle(width / 2, height / 2 - radius * 0.210526, radius * 0.260416);// 50  40





    setfillcolor(EGERGB(60, 60, 60));
    //第二圆环
    ege_fillellipse(width / 2 - radius * 0.963541, height / 2 - radius * 0.963541, radius * 0.963541 * 2, radius * 0.963541 * 2);//185
    setfillcolor(EGERGB(56, 55, 53));
    //第一圆环
    ege_fillellipse(width / 2 - radius * 0.697916, height / 2 - radius * 0.697916, 2 * radius * 0.697916, 2 * radius * 0.697916);//134
    ege_fillcircle(circle_x, circle_y, circle_r - circle_r / 30);
    //setfillcolor(EGERGB(38, 38, 38));//填充为深灰色
    //第三圈
    setcolor(EGERGB(150, 150, 150));
    setlinewidth(radius * 0.0104166);//2
    ege_circle(width / 2, height / 2, 1.1 * radius);


    screwGSI(radius, width / 2, height / 2);


    //矩形
    setfillcolor(EGERGB(25, 25, 14));
    ege_fillrect(width / 2 - radius * 0.234375, height / 2 + radius * 0.947916, radius * 0.46875, radius * 0.09375);//45  182  90  18

    //文字
    settextjustify(CENTER_TEXT, CENTER_TEXT);
    setbkmode(TRANSPARENT);
    setcolor(EGERGB(190, 190, 190));
    setfont(radius * 0.078125, radius * 0.03125, "Arial", 0, 0, 5000, true, 0, 0);// 15 6 
    ege_outtextxy(width / 2, height / 2 + radius * 0.9635416, "LAMINAR/NAV");//185


    for (double j = 0; j < radius * 0.0520833; j = j + 0.5) {
        setfillcolor(EGERGB(35, 35, 35));
        ege_fillcircle(width / 2 - radius * 0.83333 + j, height / 2 + radius * 1.04166 - j, radius * 0.165);//160  200  27
    }
    //按钮
    setfillcolor(EGERGB(55, 55, 55));
    ege_fillcircle(width / 2 - radius * 0.83333, height / 2 + radius * 1.04166, radius * 0.16);//160  200  25
    setcolor(EGERGB(190, 190, 190));
    setlinewidth(radius * 0.0052083333);//1
    ege_circle(width / 2 - radius * 0.83333, height / 2 + radius * 1.04166, radius * 0.135);  //  160  200 21
    setfont(radius * 0.1145833, radius*0.046875, "Arial", 0, 0, 5000, 0, 0, 0);//22 8
    ege_outtextxy(width / 2 - radius * 0.83333, height / 2 + radius, "OBS");//  160  192



    int i = 0;

    for (i = 0; i <= 360; i += 5)
    {
        double x1;
        double y1;
        double x2;
        double y2;
        double actual_angle = i ;
        if (actual_angle < 0) actual_angle += 360;
        setcolor(EGERGB(190, 190, 190));
        LOGFONT f;

        getfont(&f);
        setfont(radius * 0.1041666, 0, "Arial");//20
        f.lfHeight = radius * 0.188; // 设置字体高度//45
        f.lfWeight = radius * 41.66666;// 设置字体粗细//8000
        f.lfQuality = PROOF_QUALITY;
        f.lfPitchAndFamily = FF_DECORATIVE;
        f.lfEscapement = -(actual_angle + 90.0) * 10;
        settextjustify(CENTER_TEXT, CENTER_TEXT);
        setbkmode(TRANSPARENT);

        //f.lfOrientation = (actual_angle ) * 10;

        if (i % 90 == 0)
        {
            x1 = width / 2 + radius * 0.70833 * cos(PI / 180 * actual_angle);//136
            y1 = height / 2 + radius * 0.70833 * sin(PI / 180 * actual_angle);//136
            x2 = width / 2 + (radius * 0.70833 + radius * 0.041666) * cos(PI / 180 * actual_angle);//（136+8）
            y2 = height / 2 + (radius * 0.70833 + radius * 0.041666) * sin(PI / 180 * actual_angle);//（136+8）
            setlinewidth(radius * 0.0260416);//5
            ege_line(x1, y1, x2, y2);

            setfont(&f);


            if (i == 0)
            {
                //ege_outtextxy(width / 2 + 136 * cos(PI / 180 * actual_angle),
                //height / 2 + 136 * sin(PI / 180 * actual_angle),"E");
            }

            if (i == 90)
            {
                ege_outtextxy(width / 2 + radius * 0.927083 * cos(PI / 180 * actual_angle),//178
                    height / 2 + radius * 0.927083 * sin(PI / 180 * actual_angle), "S");//178
            }
            if (i == 180)
            {
                ege_outtextxy(width / 2 + radius * 0.91666 * cos(PI / 180 * actual_angle),//176
                    height / 2 + radius * 0.91666 * sin(PI / 180 * actual_angle), "W");//176
            }

            if (i == 270)
            {
                ege_outtextxy(width / 2 + radius * 0.91666 * cos(PI / 180 * actual_angle),//176
                    height / 2 + radius * 0.91666 * sin(PI / 180 * actual_angle), "N");//176
            }

            if (i == 360)
            {
                ege_outtextxy(width / 2 + radius * 0.927083 * cos(PI / 180 * actual_angle),//178
                    height / 2 + radius * 0.927083 * sin(PI / 180 * actual_angle), "E");//178
            }
            // 设置新的字体

        }
        else if (i % 30 == 0) {
            x1 = width / 2 + radius * 0.70833 * cos(PI / 180 * actual_angle);//136
            y1 = height / 2 + radius * 0.70833 * sin(PI / 180 * actual_angle);//136
            x2 = width / 2 + (radius * 0.70833 + radius * 0.072916) * cos(PI / 180 * actual_angle);//（136+14）
            y2 = height / 2 + (radius * 0.70833 + radius * 0.072916) * sin(PI / 180 * actual_angle);//（136+14）

            setlinewidth(radius * 0.015625);//3
            ege_line(x1, y1, x2, y2);
            setfont(&f);

            if (i == 30)
            {
                ege_outtextxy(width / 2 + radius * 0.9479166 * cos(PI / 180 * actual_angle),//182
                    height / 2 + radius * 0.9479166 * sin(PI / 180 * actual_angle), "12");//182
            }
            if (i == 60)
            {
                ege_outtextxy(width / 2 + radius * 0.9479166 * cos(PI / 180 * actual_angle),//182
                    height / 2 + radius * 0.9479166 * sin(PI / 180 * actual_angle), "15");//182
            }
            if (i == 120)
            {
                ege_outtextxy(width / 2 + radius * 0.9479166 * cos(PI / 180 * actual_angle),//182
                    height / 2 + radius * 0.9479166 * sin(PI / 180 * actual_angle), "21");//182
            }
            if (i == 150)
            {
                ege_outtextxy(width / 2 + radius * 0.9479166 * cos(PI / 180 * actual_angle),//182
                    height / 2 + radius * 0.9479166 * sin(PI / 180 * actual_angle), "24");//182
            }
            if (i == 210)
            {
                ege_outtextxy(width / 2 + radius * 0.9479166 * cos(PI / 180 * actual_angle),//182
                    height / 2 + radius * 0.9479166 * sin(PI / 180 * actual_angle), "30");//182
            }
            if (i == 240)
            {
                ege_outtextxy(width / 2 + radius * 0.9479166 * cos(PI / 180 * actual_angle),//182
                    height / 2 + radius * 0.9479166 * sin(PI / 180 * actual_angle), "33");//182
            }
            if (i == 300)
            {
                ege_outtextxy(width / 2 + radius * 0.9479166 * cos(PI / 180 * actual_angle),//182
                    height / 2 + radius * 0.9479166 * sin(PI / 180 * actual_angle), "3");//182
            }
            if (i == 330)
            {
                ege_outtextxy(width / 2 + radius * 0.9479166 * cos(PI / 180 * actual_angle),//182
                    height / 2 + radius * 0.9479166 * sin(PI / 180 * actual_angle), "6");//182
            }
        }
        else if (i % 10 == 0)
        {
            x1 = width / 2 + radius * 0.708333 * cos(PI / 180 * actual_angle);//136
            y1 = height / 2 + radius * 0.708333 * sin(PI / 180 * actual_angle);//136
            x2 = width / 2 + (radius * 0.708333 + radius * 0.088541) * cos(PI / 180 * actual_angle);//（136+17）
            y2 = height / 2 + (radius * 0.708333 + radius * 0.088541) * sin(PI / 180 * actual_angle);//(136+17)

            setlinewidth(radius * 0.015625);
            ege_line(x1, y1, x2, y2);
        }
        else if (i % 5 == 0)
        {
            x1 = width / 2 + radius * 0.708333 * cos(PI / 180 * actual_angle);//136
            y1 = height / 2 + radius * 0.708333 * sin(PI / 180 * actual_angle);//136
            x2 = width / 2 + (radius * 0.708333 + radius * 0.03125) * cos(PI / 180 * actual_angle);//(136+6)
            y2 = height / 2 + (radius * 0.708333 + radius * 0.03125) * sin(PI / 180 * actual_angle);//(136+6)

            setlinewidth(radius * 0.010416);
            ege_line(x1, y1, x2, y2);
        }

    }


    ege_point points1[] = { width / 2 - radius * 0.052083 * sin(PI / 180 * 22.5),height / 2 - radius * 0.052083 * cos(PI / 180 * 22.5),//10 10
                             width / 2 - radius * 0.052083 * sin(PI / 180 * 67.5),height / 2 - radius * 0.052083 * cos(PI / 180 * 67.5) ,
                             width / 2 - radius * 0.052083 * sin(PI / 180 * 112.5),height / 2 - radius * 0.052083 * cos(PI / 180 * 112.5),
                             width / 2 - radius * 0.052083 * sin(PI / 180 * 157.5),height / 2 - radius * 0.052083 * cos(PI / 180 * 157.5),
                             width / 2 - radius * 0.052083 * sin(PI / 180 * 202.5),height / 2 - radius * 0.052083 * cos(PI / 180 * 202.5),
                             width / 2 - radius * 0.052083 * sin(PI / 180 * 247.5),height / 2 - radius * 0.052083 * cos(PI / 180 * 247.5),
                             width / 2 - radius * 0.052083 * sin(PI / 180 * 292.5),height / 2 - radius * 0.052083 * cos(PI / 180 * 292.5),
                             width / 2 - radius * 0.052083 * sin(PI / 180 * 337.5),height / 2 - radius * 0.052083 * cos(PI / 180 * 337.5),
                             width / 2 - radius * 0.052083 * sin(PI / 180 * 22.5),height / 2 - radius * 0.052083 * cos(PI / 180 * 22.5) };

    setfillcolor(EGERGB(160, 160, 160));
    setlinewidth(radius * 0.0052083333);//1
    ege_fillpoly(9, points1);
    setlinewidth(radius * 0.0052083333);//1
    setfillcolor(EGERGB(50, 50, 50));
    ege_fillcircle(width / 2, height / 2, radius * 0.0338541);//6.5



    ege_point points2[] = { width / 2 - radius * 0.036458 * sin(PI / 180 * 22.5),height / 2 - radius * 0.036458 * cos(PI / 180 * 22.5) + 0.4375 * radius, //7  84
                            width / 2 - radius * 0.036458 * sin(PI / 180 * 67.5),height / 2 - radius * 0.036458 * cos(PI / 180 * 67.5) + 0.4375 * radius ,
                            width / 2 - radius * 0.036458 * sin(PI / 180 * 112.5),height / 2 - radius * 0.036458 * cos(PI / 180 * 112.5) + 0.4375 * radius,
                            width / 2 - radius * 0.036458 * sin(PI / 180 * 157.5),height / 2 - radius * 0.036458 * cos(PI / 180 * 157.5) + 0.4375 * radius,
                            width / 2 - radius * 0.036458 * sin(PI / 180 * 202.5),height / 2 - radius * 0.036458 * cos(PI / 180 * 202.5) + 0.4375 * radius,
                            width / 2 - radius * 0.036458 * sin(PI / 180 * 247.5),height / 2 - radius * 0.036458 * cos(PI / 180 * 247.5) + 0.4375 * radius,
                            width / 2 - radius * 0.036458 * sin(PI / 180 * 292.5),height / 2 - radius * 0.036458 * cos(PI / 180 * 292.5) + 0.4375 * radius,
                            width / 2 - radius * 0.036458 * sin(PI / 180 * 337.5),height / 2 - radius * 0.036458 * cos(PI / 180 * 337.5) + 0.4375 * radius,
                            width / 2 - radius * 0.036458 * sin(PI / 180 * 22.5),height / 2 - radius * 0.036458 * cos(PI / 180 * 22.5) + 0.4375 * radius };

    setfillcolor(EGERGB(160, 160, 160));
    setlinewidth(radius * 0.0052083333);//1
    ege_fillpoly(9, points2);

    setfillcolor(EGERGB(50, 50, 50));
    ege_fillcircle(width / 2, height / 2 + radius * 0.4375, radius * 0.018229);//84  3.5

    //setcolor(EGERGB(160, 160, 160));
    //setlinewidth(radius * 0.03125);//6
    //ege_line(width / 2, height / 2 + radius * 0.46875, width / 2, height / 2 - radius * 0.520833);// 90  100

    //setlinewidth(1);
    //setcolor(EGERGB(67, 65, 60));
    //ege_line(width / 2 - radius * 0.015625, height / 2 + radius * 0.46875, width / 2 - radius * 0.015625, height / 2 - radius * 0.520833);//3 90 3 100
    //ege_line(width / 2 + radius * 0.015625, height / 2 + radius * 0.46875, width / 2 + radius * 0.015625, height / 2 - radius * 0.520833);//3  90  3  100

    //一系列小圆
    setfillcolor(EGERGB(160, 160, 160));
    ege_fillcircle(width / 2 + radius * 0.09375, height / 2 + radius * 0.4322916, radius * 0.018229);// 18 83 3.5
    ege_fillcircle(width / 2 + radius * 0.1875, height / 2 + radius * 0.41666, radius * 0.018229);// 36 80
    ege_fillcircle(width / 2 + radius * 0.28125, height / 2 + radius * 0.385416, radius * 0.018229);// 54 74
    ege_fillcircle(width / 2 + radius * 0.375, height / 2 + radius * 0.34375, radius * 0.018229);// 72  66
    ege_fillcircle(width / 2 + radius * 0.46875, height / 2 + radius * 0.29166, radius * 0.018229);//  90  56
    ege_fillcircle(width / 2 - radius * 0.09375, height / 2 + radius * 0.4322916, radius * 0.018229);//  18  83
    ege_fillcircle(width / 2 - radius * 0.1875, height / 2 + radius * 0.41666, radius * 0.018229);//  36  80
    ege_fillcircle(width / 2 - radius * 0.28125, height / 2 + radius * 0.385416, radius * 0.018229);//  54  74
    ege_fillcircle(width / 2 - radius * 0.375, height / 2 + radius * 0.34375, radius * 0.018229);//  72  66
    ege_fillcircle(width / 2 - radius * 0.46875, height / 2 + radius * 0.29166, radius * 0.018229);//   90  56



    //右黑
    /*ege_point points3[] = {width / 2 + radius * 0.442708,height / 2 - radius * 0.11734,//85  23
                            width / 2 + radius * 0.572916,height / 2 - radius * 0.067708,//  110  13
                            width / 2 + radius * 0.572916,height / 2 + radius * 0.067708,//  110  13
                            width / 2 + radius * 0.442708,height / 2 + radius * 0.11734,//  85  23
                            width / 2 + radius * 0.3125,height / 2 + radius * 0.067708,//  60  13
                            width / 2 + radius * 0.3125,height / 2 - radius * 0.067708 };//  60  13
    setfillcolor(EGERGB(2, 2, 1));
    ege_fillpoly(6, points3);
    setcolor(EGERGB(250, 250, 250));
    setlinewidth(1);
    ege_line(width / 2 + 83.5, height / 2 - 22, width / 2 + 86.5, height / 2 - 22);


    ege_point points4[] = { width / 2 + radius * 0.442708,height / 2 + radius * 0.11979 ,// 85  23
                            width / 2 + radius * 0.380208,height / 2 + radius * 0.09375,//  73  18
                            width / 2 + radius * 0.505208,height / 2 + radius * 0.09375 };//  97  18
    //灰
    setfillcolor(EGERGB(42, 42, 38));
    ege_fillpoly(3, points4);
    //白
    setfillcolor(EGERGB(137, 130, 121));
    ege_fillrect(width / 2 + radius * 0.33854, height / 2 - radius * 0.03125, radius * 0.20833, radius * 0.0625);//65  6  40 12
    //红
    ege_point points5[] = { width / 2 + radius * 0.375,height / 2 - radius * 0.03125,// 72  6
                            width / 2 + radius * 0.42708,height / 2 - radius * 0.03125,//  82  3
                            width / 2 + radius * 0.390625,height / 2 + radius * 0.03125,//  75  6
                            width / 2 + radius * 0.338541,height / 2 + radius * 0.03125 };//  65  6
    setfillcolor(EGERGB(126, 35, 30));
    ege_fillpoly(4, points5);

    ege_point points6[] = { width / 2 + radius * 0.49479,height / 2 - radius * 0.03125,//95  6
                            width / 2 + radius * 0.546875,height / 2 - radius * 0.03125,//  105  6
                            width / 2 + radius * 0.510416,height / 2 + radius * 0.03125,// 98  6
                            width / 2 + radius * 0.45833,height / 2 + radius * 0.03125 };//  88  6
    ege_fillpoly(4, points6);
    */

    if (VOR2DR == 0) {
        drawVOR2N(width, height, radius);
    }
    else if (VOR2DR == 1) {
        drawVOR2T(width, height, radius);
    }
    else if (VOR2DR == 2) {
        drawVOR2F(width, height, radius);
    }
    //圆弧
    setlinewidth(radius * 0.04);//3//0.015625
    setcolor(EGERGB(40, 40, 40));
    ege_arc(width / 2 - radius * 0.177083, height / 2 - radius * 0.83333, radius * 0.354166, radius * 0.239583, 10, 160);//34  160 68  46
    ege_arc(width / 2 - radius * 0.697916, height / 2 - radius * 0.697916, 2 * radius * 0.697916, 2 * radius * 0.697916, 256, 28);//  134  134   256 28
    //ege_line(width / 2, height / 2 - radius*0.6875, width / 2, height / 2 - radius*0.6822916);// 132  131
    setfillcolor(EGERGB(40, 40, 40));
    floodfill(width / 2, height / 2 - radius * 0.671875, EGERGB(40, 40, 40));//129


    //黄色三角

    ege_point points7[] = { width / 2 - radius * 0.041666,height / 2 + radius * 0.651041,//8  125
                            width / 2 + radius * 0.041666,height / 2 + radius * 0.651041,// 8  125
                            width / 2,height / 2 + radius * 0.703125 };//   135
    setfillcolor(EGERGB(156, 141, 74));
    ege_fillpoly(3, points7);

    ege_point points8[] = { width / 2 - radius * 0.067708,height / 2 - radius * 0.58333,//  13  112
                            width / 2 + radius * 0.067708,height / 2 - radius * 0.58333,//  13  112
                            width / 2,height / 2 - radius * 0.703125 };//  135

    ege_fillpoly(3, points8);

    if (dot > 2.5) {
        dot = 2.5;
    }
    if (dot < -2.5) {
        dot = -2.5;
    }
    drawVOR1Line1(width, height,  radius, dot);
    
    //    getch();
}
void drawVOR2N(double width, double height, double radius)
{
    //右黑
    ege_point points3[] = { width / 2 + radius * 0.442708,height / 2 - radius * 0.11734,//85  23
                            width / 2 + radius * 0.572916,height / 2 - radius * 0.067708,//  110  13
                            width / 2 + radius * 0.572916,height / 2 + radius * 0.067708,//  110  13
                            width / 2 + radius * 0.442708,height / 2 + radius * 0.11734,//  85  23
                            width / 2 + radius * 0.3125,height / 2 + radius * 0.067708,//  60  13
                            width / 2 + radius * 0.3125,height / 2 - radius * 0.067708 };//  60  13
    setfillcolor(EGERGB(2, 2, 1));
    ege_fillpoly(6, points3);
    setcolor(EGERGB(250, 250, 250));
    setlinewidth(radius * 0.0052083333);//1
    ege_line(width / 2 + radius * 0.4348958, height / 2 - 0.114583 * radius, width / 2 + radius * 0.447916, height / 2 - radius * 0.114583);


    ege_point points4[] = { width / 2 + radius * 0.442708,height / 2 + radius * 0.11979 ,// 85  23
                            width / 2 + radius * 0.380208,height / 2 + radius * 0.09375,//  73  18
                            width / 2 + radius * 0.505208,height / 2 + radius * 0.09375 };//  97  18
    //灰
    setfillcolor(EGERGB(42, 42, 38));
    ege_fillpoly(3, points4);
    //白
    setfillcolor(EGERGB(137, 130, 121));
    ege_fillrect(width / 2 + radius * 0.33854, height / 2 - radius * 0.03125, radius * 0.20833, radius * 0.0625);//65  6  40 12
    //红
    ege_point points5[] = { width / 2 + radius * 0.375,height / 2 - radius * 0.03125,// 72  6
                            width / 2 + radius * 0.42708,height / 2 - radius * 0.03125,//  82  3
                            width / 2 + radius * 0.390625,height / 2 + radius * 0.03125,//  75  6
                            width / 2 + radius * 0.338541,height / 2 + radius * 0.03125 };//  65  6
    setfillcolor(EGERGB(126, 35, 30));
    ege_fillpoly(4, points5);

    ege_point points6[] = { width / 2 + radius * 0.49479,height / 2 - radius * 0.03125,//95  6
                            width / 2 + radius * 0.546875,height / 2 - radius * 0.03125,//  105  6
                            width / 2 + radius * 0.510416,height / 2 + radius * 0.03125,// 98  6
                            width / 2 + radius * 0.45833,height / 2 + radius * 0.03125 };//  88  6
    ege_fillpoly(4, points6);
}
void drawVOR2F(double width, double height, double radius)
{
    //右黑
    ege_point points3[] = { width / 2 + radius * 0.442708,height / 2 - radius * 0.11734,//85  23
                            width / 2 + radius * 0.572916,height / 2 - radius * 0.067708,//  110  13
                            width / 2 + radius * 0.572916,height / 2 + radius * 0.067708,//  110  13
                            width / 2 + radius * 0.442708,height / 2 + radius * 0.11734,//  85  23
                            width / 2 + radius * 0.3125,height / 2 + radius * 0.067708,//  60  13
                            width / 2 + radius * 0.3125,height / 2 - radius * 0.067708 };//  60  13
    setfillcolor(EGERGB(2, 2, 1));
    ege_fillpoly(6, points3);
    setcolor(EGERGB(250, 250, 250));
    setlinewidth(radius * 0.0052083333);//1
    ege_line(width / 2 + radius * 0.4348958, height / 2 - 0.114583 * radius, width / 2 + radius * 0.447916, height / 2 - radius * 0.114583);
    ege_point points4[] = { width / 2 + radius * 0.442708,height / 2 + radius * 0.1,
                            width / 2 + radius * 0.55,height / 2 + radius * 0.06 ,
                            width / 2 + radius * 0.55,height / 2 + radius * 0.04,
                            width / 2 + radius * 0.33,height / 2 + radius * 0.04,
                            width / 2 + radius * 0.33,height / 2 + radius * 0.06 };
    setfillcolor(EGERGB(156, 150, 150));
    ege_fillpoly(5, points4);

    //FROM
    settextjustify(CENTER_TEXT, CENTER_TEXT);
    setbkmode(TRANSPARENT);
    setcolor(EGERGB(230, 230, 230));
    setfont(radius * 0.078125, radius * 0.02604166, "Arial", 0, 0, radius * 5.208333, 0, 0, 0);//15 5
    ege_outtextxy(width / 2 + radius * 0.442708, height / 2 - radius * 0.03, "F R O M");//30 34
}
void drawVOR2T(double width, double height, double radius)
{
    //右黑
    ege_point points3[] = { width / 2 + radius * 0.442708,height / 2 - radius * 0.11734,//85  23
                            width / 2 + radius * 0.572916,height / 2 - radius * 0.067708,//  110  13
                            width / 2 + radius * 0.572916,height / 2 + radius * 0.067708,//  110  13
                            width / 2 + radius * 0.442708,height / 2 + radius * 0.11734,//  85  23
                            width / 2 + radius * 0.3125,height / 2 + radius * 0.067708,//  60  13
                            width / 2 + radius * 0.3125,height / 2 - radius * 0.067708 };//  60  13
    setfillcolor(EGERGB(2, 2, 1));
    ege_fillpoly(6, points3);
    setcolor(EGERGB(250, 250, 250));
    setlinewidth(radius * 0.0052083333);//1
    ege_line(width / 2 + radius * 0.4348958, height / 2 - 0.114583 * radius, width / 2 + radius * 0.447916, height / 2 - radius * 0.114583);
    ege_point points4[] = { width / 2 + radius * 0.442708,height / 2 - radius * 0.09
        ,width / 2 + radius * 0.55,height / 2 - radius * 0.05,
        width / 2 + radius * 0.55,height / 2 - radius * 0.025,
        width / 2 + radius * 0.33,height / 2 - radius * 0.025,
        width / 2 + radius * 0.33,height / 2 - radius * 0.05 };
    setfillcolor(EGERGB(156, 150, 150));
    ege_fillpoly(5, points4);
    //TO
    settextjustify(CENTER_TEXT, CENTER_TEXT);
    setbkmode(TRANSPARENT);
    setcolor(EGERGB(230, 230, 230));
    setfont(radius * 0.078125, radius * 0.02604166, "Arial", 0, 0, 8000, 0, 0, 0);//15 5
    ege_outtextxy(width / 2 + radius * 0.442708, height / 2 - radius * 0.015, "TO");//30 34

}


void drawVOR1Line1(double width, double height, double radius, double dot)
{

    double t = dot * 8.5;//10.5
    setcolor(EGERGB(160, 160, 160));
    setlinewidth(radius * 0.03125);
    ege_line(width / 2 + radius * 1.448 * sin(t * PI / 180), height / 2 - radius * 0.989583 + radius * 1.448 * cos(t * PI / 180), width / 2 + radius * 0.427083 * sin(t * PI / 180), height / 2 - radius * 0.989583 + radius * 0.427083 * cos(t * PI / 180));//282   190 82

    setlinewidth(radius * 0.0052083333);//1
    setcolor(EGERGB(67, 65, 60));
    //ege_line(width / 2 +  radius*1.448 * sin(t * PI / 180 + 0.8 * PI / 180), height / 2 - radius * 0.989583 + radius * 1.448 * cos(t * PI / 180 + 0.8 * PI / 180), width / 2 + radius * 0.427083 * sin(t * PI / 180 + 1.5 * PI / 180), height / 2 - radius * 0.989583 + radius * 0.427083 * cos(t * PI / 180 + 1.5* PI / 180));//3 64 3 105
    //ege_line(width / 2 + radius * 1.448 * sin(t * PI / 180 - 0.8 * PI / 180), height / 2 - radius * 0.989583 + radius * 1.448 * cos(t * PI / 180 - 0.8 * PI / 180), width / 2 + radius * 0.427083 * sin(t * PI / 180 - 1.5 * PI / 180), height / 2 - radius * 0.989583 + radius * 0.427083 * cos(t * PI / 180 - 1.5* PI / 180));//3 64 3 105

}
void screwGSI(double DIAL_RADIUS, double CENTER_X, double CENTER_Y)//螺丝
{
    // 使用float保证计算精度（根据需求可改为double）
    const float DIAL_RADIUS_F = (float)DIAL_RADIUS;
    const float CENTER_X_F = (float)CENTER_X;
    const float CENTER_Y_F = (float)CENTER_Y;

    // 参数化定义（精确到小数点后6位）
    const float SCREW_OFFSET = DIAL_RADIUS_F * 0.055555556f; // 1/18
    const float ELLIPSE_OFFSET_X = -DIAL_RADIUS_F * 0.111111111f; // -1/9
    const float ELLIPSE_OFFSET_Y = -DIAL_RADIUS_F * 0.166666667f; // -1/6
    const float ELLIPSE_SIZE = DIAL_RADIUS_F * 0.277777778f;  // 5/18
    const float RECT_OFFSET_X = DIAL_RADIUS_F * 0.222222222f;  // 2/9
    const float RECT_OFFSET_Y = DIAL_RADIUS_F * 0.333333333f;  // 1/3
    const float RECT_WIDTH = DIAL_RADIUS_F * 0.555555556f;   // 5/9
    const float RECT_HEIGHT = DIAL_RADIUS_F * 0.611111111f;  // 11/18
    const float CROSS_OFFSET1 = DIAL_RADIUS_F * 0.055555556f;  // 1/18
    const float CROSS_OFFSET2 = DIAL_RADIUS_F * 0.027777778f;  // 1/36
    const float LINE_WIDTH = DIAL_RADIUS_F * 0.016666667f;  // 1/60

    ege_enable_aa(TRUE);

    // 绘制函数（使用浮点坐标）
    auto draw_screw = [&](float cx, float cy) {
        // 精确到小数点后6位的渐变参数
        ege_setpattern_ellipsegradient(
            ege_point{ roundf(cx), roundf(cy) }, // 最终转整数
            EGEACOLOR(0xFF, BLACK),
            roundf(cx + ELLIPSE_OFFSET_X),
            roundf(cy + ELLIPSE_OFFSET_Y),
            roundf(ELLIPSE_SIZE),
            roundf(ELLIPSE_SIZE),
            EGEACOLOR(0, WHITE)
        );
        ege_fillrect(
            roundf(cx - RECT_OFFSET_X),
            roundf(cy - RECT_OFFSET_Y),
            roundf(RECT_WIDTH),
            roundf(RECT_HEIGHT)
        );

        // 灰色渐变层（精确尺寸调整）
        const float adjusted_size = ELLIPSE_SIZE - DIAL_RADIUS_F * 0.055555556f; // 替代原-10
        ege_setpattern_ellipsegradient(
            ege_point{
                    roundf(cx - SCREW_OFFSET * 0.5f),
                    roundf(cy - SCREW_OFFSET * 0.5f)
            },
            EGEACOLOR(0xFF, EGERGB(170, 170, 170)),
            roundf(cx + ELLIPSE_OFFSET_X),
            roundf(cy + ELLIPSE_OFFSET_Y),
            roundf(adjusted_size),
            roundf(adjusted_size),
            EGEACOLOR(0xFF, EGERGB(20, 20, 20))
        );
        ege_fillrect(
            roundf(cx - RECT_OFFSET_X),
            roundf(cy - RECT_OFFSET_Y),
            roundf(RECT_WIDTH),
            roundf(RECT_HEIGHT)
        );

        // 十字线（亚像素级精度）
        setcolor(EGERGB(30, 30, 30));
        setlinewidth(roundf(LINE_WIDTH));

        const float cross_y = cy - CROSS_OFFSET2 * 2.0f;
        ege_line(
            roundf(cx - CROSS_OFFSET1), roundf(cross_y),
            roundf(cx + CROSS_OFFSET1), roundf(cross_y)
        );

        const float cross_x = cx;
        const float cross_y_start = cy + CROSS_OFFSET2 / 4;
        const float cross_y_end = cy - CROSS_OFFSET2 * 4.0f;
        ege_line(
            roundf(cross_x), roundf(cross_y_start),
            roundf(cross_x), roundf(cross_y_end)
        );
        };

    // 计算四个螺丝中心坐标（浮点运算）
    const float screw_radius = DIAL_RADIUS_F - SCREW_OFFSET;

    // 左上
    draw_screw(
        CENTER_X_F - screw_radius,
        CENTER_Y_F - DIAL_RADIUS_F
    );

    // 右上
    draw_screw(
        CENTER_X_F + screw_radius,
        CENTER_Y_F - DIAL_RADIUS_F
    );

    // 右下
    draw_screw(
        CENTER_X_F + screw_radius,
        CENTER_Y_F + DIAL_RADIUS_F
    );

    // 左下（新增）
    //draw_screw(
    //CENTER_X_F - screw_radius,
    //CENTER_Y_F + DIAL_RADIUS_F
    //);
}
